<?php /*a:1:{s:63:"/www/wwwroot/103.151.217.18/app/admin/view/main/build_keys.html";i:1685273186;}*/ ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>工作台</title>
  <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
  <link rel="stylesheet" href="/static/assets/module/admin.css?v=318"/>
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
  <style>
    /** 应用快捷块样式 */
    .console-app-group {
      padding: 16px;
      border-radius: 4px;
      text-align: center;
      background-color: #fff;
      cursor: pointer;
      display: block;
    }

    .console-app-group .console-app-icon {
      width: 32px;
      height: 32px;
      line-height: 32px;
      margin-bottom: 6px;
      display: inline-block;
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
      font-size: 32px;
      color: #69c0ff;
    }

    .console-app-group:hover {
      box-shadow: 0 0 15px rgba(0, 0, 0, .08);
    }

    /** //应用快捷块样式 */

    /** 小组成员 */
    .console-user-group {
      position: relative;
      padding: 10px 0 10px 60px;
    }

    .console-user-group .console-user-group-head {
      width: 32px;
      height: 32px;
      position: absolute;
      top: 50%;
      left: 12px;
      margin-top: -16px;
      border-radius: 50%;
    }

    .console-user-group .layui-badge {
      position: absolute;
      top: 50%;
      right: 8px;
      margin-top: -10px;
    }

    .console-user-group .console-user-group-name {
      line-height: 1.2;
    }

    .console-user-group .console-user-group-desc {
      color: #8c8c8c;
      line-height: 1;
      font-size: 12px;
      margin-top: 5px;
    }

    /** 卡片轮播图样式 */
    .admin-carousel .layui-carousel-ind {
      position: absolute;
      top: -41px;
      text-align: right;
    }

    .admin-carousel .layui-carousel-ind ul {
      background: 0 0;
    }

    .admin-carousel .layui-carousel-ind li {
      background-color: #e2e2e2;
    }

    .admin-carousel .layui-carousel-ind li.layui-this {
      background-color: #999;
    }

    /** 广告位轮播图 */
    .admin-news .layui-carousel-ind {
      height: 45px;
    }

    .admin-news a {
      display: block;
      line-height: 70px;
      text-align: center;
    }

    /** 最新动态时间线 */
    .layui-timeline-dynamic .layui-timeline-item {
      padding-bottom: 0;
    }

    .layui-timeline-dynamic .layui-timeline-item:before {
      top: 16px;
    }

    .layui-timeline-dynamic .layui-timeline-axis {
      width: 9px;
      height: 9px;
      left: 1px;
      top: 7px;
      background-color: #cbd0db;
    }

    .layui-timeline-dynamic .layui-timeline-axis.active {
      background-color: #0c64eb;
      box-shadow: 0 0 0 2px rgba(12, 100, 235, .3);
    }

    .dynamic-card-body {
      box-sizing: border-box;
      overflow: hidden;
    }

    .dynamic-card-body:hover {
      overflow-y: auto;
      padding-right: 9px;
    }

    /** 优先级徽章 */
    .layui-badge-priority {
      border-radius: 50%;
      width: 20px;
      height: 20px;
      padding: 0;
      line-height: 18px;
      border-width: 2px;
      font-weight: 600;
    }
  </style>
</head>
<body>
<!-- 修改密码表单 -->
<form class="layui-form model-form">
  <div class="layui-form-item ">
    <label class="layui-form-label layui-form-required">数量</label>
    <div class="layui-input-block">
      <input type="text" name="number" required  lay-verify="required" placeholder="请输入生成数量" class="layui-input" value="10">
    </div>
  </div>
  <div class="layui-form-item ">
    <label class="layui-form-label layui-form-required">天数</label>
    <div class="layui-input-block">
      <input type="text" name="time" required  lay-verify="required" placeholder="天数" class="layui-input" value="30">
    </div>
  </div>
  <div class="layui-form-item ">
    <label class="layui-form-label">备注</label>
    <div class="layui-input-block">
      <input type="text" name="remarks" placeholder="备注" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label layui-form-required">卡密列表</label>
    <div class="layui-input-block">
      <textarea name="keys" id="keys" style="height:400px;" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block" style="display: flex;justify-content: space-between">
      <div>
        <button class="layui-btn" type="button" onclick="buid()">确认生成</button>
      </div>
      <div>
        <button class="layui-btn layui-btn-normal" lay-filter="submit" type="button" lay-submit>确认入库</button>
      </div>
    </div>
  </div>
</form>

<!-- js部分 -->
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/static/assets/js/common.js?v=318"></script>
<script>
  layui.use(['layer', 'form', 'admin', 'formX'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var admin = layui.admin;

    // 监听提交
    form.on('submit(submit)', function (data) {
      // 替换key中的换行内容
      data.field.keys = data.field.keys.replace(/\n/g, ',');
      $.post("<?php echo url('admin/main/cdkeyAdd'); ?>", data.field, function (res) {
        if (res.code === 200) {
          layer.msg(res.msg, {icon: 1});
        } else {
          layer.msg(res.msg, {icon: 2});
        }
      }, 'json');
      return false;
    });

    // 生成卡密
    window.buid = function (){
      let num = $('input[name="number"]').val();
      // 生成指定数量的卡密
      for (let i = 0; i < num; i++) {
        let key = sendk();
        $('#keys').append(key + '\n');
      }
    }
    window.sendk = function (){
      let key = "";
      let str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
      for(let i=0;i<16;i++){
        key += str.charAt(Math.floor(Math.random()*str.length));
      }
      return key;
    }
  });
</script>
</body>
</html>
